/**
 *
 */
package com.angel.common.providers.actions;

import java.lang.reflect.Field;

import com.angel.annotation.interfaces.AnnotationAction;
import com.angel.annotation.managers.AnnotationManager;
import com.angel.common.helpers.ReflectionHelper;
import com.angel.common.providers.annotations.RangeValue;
import com.angel.common.providers.enums.RangeValueType;


/**
 * @author William
 *
 */
public class MinimumFieldRangeValueAnnotationAction implements AnnotationAction{

	public static final RangeValueType RANGE_VALUE_TYPE = RangeValueType.MINIMUN;

	public Object doAction(AnnotationManager annotationManager, Object object) {
		Field field = ReflectionHelper.getAllFieldWith(annotationManager.getClassAnnotation(), object.getClass())[0];
		Comparable<?> minimunComparableObject = (Comparable<?>) ReflectionHelper.getObjectForField(object, field);
		return minimunComparableObject;
	}

	public Boolean isDefault() {
		return true;
	}

	public Boolean canDoActionFor(AnnotationManager annotationManager, Object object) {
		Field field = ReflectionHelper.getAllFieldWith(annotationManager.getClassAnnotation(), object.getClass())[0];
		RangeValue fieldAnnotation = (RangeValue) field.getAnnotation(annotationManager.getClassAnnotation());
		return RANGE_VALUE_TYPE == fieldAnnotation.type();
	}

	public Object doAction(AnnotationManager annotationManager, Object object,
			Object targetObject, Object[] parameters) {
		// TODO Auto-generated method stub
		return null;
	}


}
